{include admin.inc.header}

{include admin.inc.top}

<div class="container-fluid content-body">
	<div class="main">
		{include admin.inc.menu}

		<section class="right-section" id="right-section">
			<!-- start of inner-frame -->
			<div class="inner-iframe">

				{include admin.inc.bread}

				<!-- Nav tabs -->
				<ul class="nav nav-tabs">
					{loop $__sysmenus[$menu_key][subs] $k $v}
					<li{if $v[id]==$menu_id} class="active"{/if}><a href="{if $v[id]==$menu_id}javascript:;{else}/{$v[url]}{/if}"><i class="glyphicon glyphicon-th-list"></i> {$v[name]}</a></li>
					{/loop}
				</ul>

				<div class="inner-container">
					<nav class="inline-form clearfix">
						<a class="btnlg mb fl" id="content-add" href="javascript:;"><i class="css-add"></i>添加应用</a>
					</nav>
					<form id="J_List_Form">
						<div class="table-responsive">
							<table class="table table-bordered table-hover" id="J_List_Table">
								<thead>
								<tr>
									<th width="20"><input type="checkbox" class="icheck check-all" /></th>
									<th>应用名称</th>
									<th>安装次数</th>
									<th>api秘钥</th>
									<th>应用状态</th>
									<th>添加时间</th>
									<th>操作</th>
								</tr>
								</thead>
								<tbody>
								{if empty($items)}
								<tr>
									<td class="no-records text-center">{$noRecords}</td>
								</tr>
								{/if}
								{loop $items $value}
								<tr>
									<td><input type="checkbox" class="icheck" name="ids[]" id="checkbox_row_{$value[id]}" /></td>
									<td><label for="checkbox_row_{$value[id]}">{$value[name]}</label></td>
									<td>{$value[install_num]}</td>
									<td>{$value[secret_key]}</td>
									<td>
										<div class="bootstrap-switch-swrap">
											<input type="checkbox" data-id="{$value[id]}" data-field="status" class="bswitch bswitch-list" data-size="mini"
												   {if $value[status]==1}checked{/if} data-on-text="销售中" data-off-text="已下架">
										</div>
									</td>
									<td>{$value[addtime]}</td>
									<td>
										{if $loginUser->hasPermission('admin/app/update')}
										<a href="javascript:;" data-id="{$value[id]}" class="btn btn-primary btn-xs item-edit">
											<i class="glyphicon glyphicon-edit"></i> 修改</a>
										{/if}
										{if $loginUser->hasPermission('admin/app/delete')}
										<a href="{$delete_url}/?id={$value[id]}" class="btn btn-danger btn-xs item-remove">
											<i class="glyphicon glyphicon-trash"></i> 删除</a>
										{/if}
									</td>
								</tr>
								{/loop}
								</tbody>
							</table>
						</div>
					</form>

					<div class="text-right">
						{$pagemenu}
					</div>

				</div>

			</div><!-- end of inner -->
		</section>

	</div>
</div>

{include admin.inc.footer}

<script type="text/html" id="content-add-template">

	<form role="form" class="content-add-form" id="content-add-form" autocomplete="off">

		<div class="form-element">
			<div class="form-group">
				<label><span class="asterisk">*</span> 应用名称</label>
				<input type="text" name="data[name]" value="{[item.name]}" class="form-control" maxlength="30" placeholder="应用名称" required />
			</div>
			<p class="help-block"></p>
		</div>

		<div class="form-element">
			<div class="form-group">
				<label>应用简介</label>
				<textarea class="form-control" name="data[summary]">{[item.summary]}</textarea>
			</div>
			<p class="help-block"></p>
		</div>

		<div class="form-element">
			<div class="form-group">
				<label>销售状态</label>
				<!--<div>
					<input type="checkbox" class="bswitch bswitch-add" {[if item.status == 1 ]}checked{[/if]} data-on-text="销售中" data-off-text="已下架">
					<input type="hidden" name="data[status]" value="{[item.status]}">
				</div>-->
					<div class="bootstrap-switch-swrap">
						<input type="checkbox" class="bswitch bswitch-list" data-size="mini" {[if item.status == 1 ]}checked{[/if]} data-on-text="销售中" data-off-text="已下架">
						<input type="hidden" name="data[status]" value="{[item.status]}">
					</div>

			</div>
			<p class="help-block"></p>
		</div>

		<input type="hidden" name="id" value="{[item.id]}">
	</form>
</script>

<script>
	seajs.use("app", function(exports) {
		exports.init({
			set_url : '/admin/app/set/',
			insert_url : '{$insert_url}',
			edit_url : '{$edit_url}',
			update_url : '{$update_url}',
		});
	});
</script>
</body>
</html>
